#ifndef CRPC_EVENT_LOOP_H
#define CRPC_EVENT_LOOP_H

#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct FdMask FdMask;
struct FdMask {
    int fd;
    unsigned int mask;
};

typedef struct EventLoop EventLoop;
struct EventLoop {
    int maxFd;
    int setSize;
    FdMask *fdMasks;
    int stop;
    int epfd;
    struct epoll_event *epEvents;
};

EventLoop *CreateEventLoop(int size);
void DestroyEventLoop(EventLoop *loop);
void StopEventLoop(EventLoop *loop);
int AddFdEvent(EventLoop *loop, int fd, unsigned int addMask);
int DelFdEvent(EventLoop *loop, int fd, unsigned int delMask);

#ifdef __cplusplus
}
#endif
#endif